//
// Created by zhuyijun on 2021/8/23.
//

#ifndef BASE_BRASS_H
#define BASE_BRASS_H

#include <string>

/**
 * 虚函数会根据对象类型来判断执行那个对象的虚方法
 *
 * 有元不能是虚函数（友元不是成员函数）
 */
class Brass {
private:
    std::string fullName;
    long accNum;
    double balance;
public:
    Brass(const std::string &s = "Nullbody", long an = -1, double bal = 0.0);

    void Deposit(double amt);

    //虚函数
    virtual void Withdraw(double amt);

    double Balance() const;

    //虚函数
    virtual void ViewAcct() const;

    virtual ~Brass() {};
};

class BrassPlus : public Brass {
private:
    double maxLoan;
    double rate;
    double owesBank;
public:
    BrassPlus(const std::string &s = "NullBody", long an = -1, double bal = 0.0, double ml = 500, double r = 0.11125);

    BrassPlus(const Brass &ba, double ml = 500, double r = 0.11125);

    //虚函数
    virtual void ViewAcct() const;

    //虚函数
    virtual void Withdraw(double amt);

    //析构函数也是虚函数
    virtual ~BrassPlus() {};

    void ResetMax(double m) {
        maxLoan = m;
    }

    void ResetRate(double r) {
        rate = r;
    }

    void ResetOwes() {
        owesBank = 0;
    }

};

#endif //BASE_BRASS_H
